package org.magnerfuller.imtoolkit.server.naming;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class NamedModuleDirectory {
  protected Map<String, Class> directory;
  
  public NamedModuleDirectory() {
    directory = new HashMap<String, Class>();
  }
  
  public Class lookupModule(String name) {
    return directory.get(name);
  }

  public void addModule(Class module) {
    try {
      directory.put((String)module.getField("moduleName").get(module), module);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  
  public void addModule(Class module, String moduleName) {
    directory.put(moduleName, module);
  }
  
  public Set<String> getModuleNames() {
    return directory.keySet();
  }
}
